/* 
 * wctype.h
 *
 * Functions for testing wide character types and converting characters.
 *
 * This file is part of the clang api package.
 *
 * Contributors:
 *  Created by Yingkui Ma <@>
 *
 *  THIS SOFTWARE IS NOT COPYRIGHTED
 *
 *  This source code is offered for use in the public domain. You may
 *  use, modify or distribute it freely.
 *
 *  This code is distributed in the hope that it will be useful but
 *  WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
 *  DISCLAIMED. This includes but is not limited to warranties of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 *
 */

#ifndef _CLANG_PORT_WCTYPE_H_
#define _CLANG_PORT_WCTYPE_H_

/* All the headers include this file. */
#ifndef __IMPL_CLANG_PORT_API_
#	include <_clang_port.h>
#else
#	include <include/_clang_port.h>
#endif

#include <stddef.h>

#ifndef __IMPL_CLANG_PORT_API_
/*
 * The following flags are used to tell iswctype and _isctype what character
 * types you are looking for.
 */
#define	_UPPER		0x0001
#define	_LOWER		0x0002
#define	_DIGIT		0x0004
#define	_SPACE		0x0008
#define	_PUNCT		0x0010
#define	_CONTROL	0x0020
#define	_BLANK		0x0040
#define	_HEX		0x0080
#define	_LEADBYTE	0x8000

#define	_ALPHA		0x0103

#ifndef WEOF
#define	WEOF	(wchar_t)(0xFFFF)
#endif

typedef wchar_t wctype_t;
typedef wchar_t wctrans_t;


#endif // __IMPL_CLANG_PORT_API_

#ifdef __cplusplus
extern "C" {
#endif


/* 
 * Clang Hook Api.
*/
	typedef int CLANG_PORT_FPTR_TYPE(iswalnum)(wint_t);
	extern CLANG_PORT_FPTR_VAR(iswalnum);
	typedef int CLANG_PORT_FPTR_TYPE(iswalpha)(wint_t);
	extern CLANG_PORT_FPTR_VAR(iswalpha);
	typedef int CLANG_PORT_FPTR_TYPE(iswascii)(wint_t);
	extern CLANG_PORT_FPTR_VAR(iswascii);
	typedef int CLANG_PORT_FPTR_TYPE(iswcntrl)(wint_t);
	extern CLANG_PORT_FPTR_VAR(iswcntrl);
	typedef int CLANG_PORT_FPTR_TYPE(iswctype)(wint_t, wctype_t);
	extern CLANG_PORT_FPTR_VAR(iswctype);
	typedef int CLANG_PORT_FPTR_TYPE(iswdigit)(wint_t);
	extern CLANG_PORT_FPTR_VAR(iswdigit);
	typedef int CLANG_PORT_FPTR_TYPE(iswgraph)(wint_t);
	extern CLANG_PORT_FPTR_VAR(iswgraph);
	typedef int CLANG_PORT_FPTR_TYPE(iswlower)(wint_t);
	extern CLANG_PORT_FPTR_VAR(iswlower);
	typedef int CLANG_PORT_FPTR_TYPE(iswprint)(wint_t);
	extern CLANG_PORT_FPTR_VAR(iswprint);
	typedef int CLANG_PORT_FPTR_TYPE(iswpunct)(wint_t);
	extern CLANG_PORT_FPTR_VAR(iswpunct);
	typedef int CLANG_PORT_FPTR_TYPE(iswspace)(wint_t);
	extern CLANG_PORT_FPTR_VAR(iswspace);
	typedef int CLANG_PORT_FPTR_TYPE(iswupper)(wint_t);
	extern CLANG_PORT_FPTR_VAR(iswupper);
	typedef int CLANG_PORT_FPTR_TYPE(iswxdigit)(wint_t);
	extern CLANG_PORT_FPTR_VAR(iswxdigit);
	typedef int CLANG_PORT_FPTR_TYPE(iswblank )(wint_t);
	extern CLANG_PORT_FPTR_VAR(iswblank);
	typedef wint_t CLANG_PORT_FPTR_TYPE(towlower )(wint_t);
	extern CLANG_PORT_FPTR_VAR(towlower);
	typedef wint_t CLANG_PORT_FPTR_TYPE(towupper )(wint_t);
	extern CLANG_PORT_FPTR_VAR(towupper);
	typedef wint_t CLANG_PORT_FPTR_TYPE(towctrans)(wint_t, wctrans_t);
	extern CLANG_PORT_FPTR_VAR(towctrans);
	typedef wctrans_t CLANG_PORT_FPTR_TYPE(wctrans)(const char*);
	extern CLANG_PORT_FPTR_VAR(wctrans);
	typedef wctype_t CLANG_PORT_FPTR_TYPE(wctype)(const char*);
	extern CLANG_PORT_FPTR_VAR(wctype);
	
#ifndef __IMPL_CLANG_PORT_API_
/*
 * STD C Api.
 */
CLANG_PORT_INLINE int iswalnum(wint_t w)
{
	return CLANG_PORT_CALL_FPTR(iswalnum)(w);
}
CLANG_PORT_INLINE int iswalpha(wint_t w)
{
	return CLANG_PORT_CALL_FPTR(iswalpha)(w);
}
CLANG_PORT_INLINE int iswascii(wint_t w)
{
	return CLANG_PORT_CALL_FPTR(iswascii)(w);
}
CLANG_PORT_INLINE int iswcntrl(wint_t w)
{
	return CLANG_PORT_CALL_FPTR(iswcntrl)(w);
}
CLANG_PORT_INLINE int iswctype(wint_t w, wctype_t c)
{
	return CLANG_PORT_CALL_FPTR(iswctype)(w,c);
}
CLANG_PORT_INLINE int iswdigit(wint_t w)
{
	return CLANG_PORT_CALL_FPTR(iswdigit)(w);
}
CLANG_PORT_INLINE int iswgraph(wint_t w)
{
	return CLANG_PORT_CALL_FPTR(iswgraph)(w);
}
CLANG_PORT_INLINE int iswlower(wint_t w)
{
	return CLANG_PORT_CALL_FPTR(iswlower)(w);
}
CLANG_PORT_INLINE int iswprint(wint_t w)
{
	return CLANG_PORT_CALL_FPTR(iswprint)(w);
}
CLANG_PORT_INLINE int iswpunct(wint_t w)
{
	return CLANG_PORT_CALL_FPTR(iswpunct)(w);
}
CLANG_PORT_INLINE int iswspace(wint_t w)
{
	return CLANG_PORT_CALL_FPTR(iswspace)(w);
}
CLANG_PORT_INLINE int iswupper(wint_t w)
{
	return CLANG_PORT_CALL_FPTR(iswupper)(w);
}
CLANG_PORT_INLINE int iswxdigit(wint_t w)
{
	return CLANG_PORT_CALL_FPTR(iswxdigit)(w);
}
CLANG_PORT_INLINE int __cdecl iswblank (wint_t w)
{
	return CLANG_PORT_CALL_FPTR(iswblank)(w);
}
CLANG_PORT_INLINE wint_t towlower (wint_t w)
{
	return CLANG_PORT_CALL_FPTR(towlower)(w);
}
CLANG_PORT_INLINE wint_t towupper (wint_t w)
{
	return CLANG_PORT_CALL_FPTR(towupper)(w);
}
CLANG_PORT_INLINE wint_t 	towctrans(wint_t w , wctrans_t t)
{
	return CLANG_PORT_CALL_FPTR(towctrans)(w,t);
}
CLANG_PORT_INLINE wctrans_t wctrans(const char* t)
{
	return CLANG_PORT_CALL_FPTR(wctrans)(t);
}
CLANG_PORT_INLINE wctype_t wctype(const char* t)
{
	return CLANG_PORT_CALL_FPTR(wctype)(t);
}

#endif /* __IMPL_CLANG_PORT_API_ */

#ifdef __cplusplus
}
#endif


#endif	/* Not _CLANG_PORT_WCTYPE_H_ */

